package org.example;

import org.example.entity.Course;
import org.example.entity.Student;

public class SystemInit {
    public void init(StudentManager manager) {
        initStudent(manager);
        initCourse(manager);
        initElectives(manager);
    }

    public void initStudent(StudentManager manager) {
        // 学生信息列表，可以方便地添加更多学生
        String[][] students = {
                {"001", "aaa"},
                {"002", "bbb"},
                {"003", "ccc"},
                {"004", "ddd"},
                {"005", "eee"},
                {"006", "fff"},
                {"007", "ggg"},
                {"008", "hhh"},
                {"009", "iii"}
        };

        // 遍历学生信息列表，创建学生对象并添加到manager中
        for (String[] info : students) {
            Student student = new Student(info[0], info[1]);
            manager.addStudent(student);
        }
    }

    public void initCourse(StudentManager manager) {
        // 定义课程信息的二维数组
        String[][] coursesInfo = {
                {"CS001", "数据结构", "5"},
                {"CS002", "计算机组成原理", "4"},
                {"CS003", "计算机网络", "3"},
                {"CS004", "操作系统", "2"},
                {"CS005", "编译原理", "5"},
                {"CS006", "汇编语言", "2"},
                {"CS007", "数据库系统原理", "3"}
        };

        // 循环遍历课程信息，创建Course对象并添加到manager中
        for (String[] info : coursesInfo) {
            Course course = new Course(info[0], info[1], Integer.parseInt(info[2]));
            manager.addCourse(course);
        }
    }

    public void initElectives(StudentManager manager) {
        manager.studentSelectCourse("001", "CS001");
        manager.studentSelectCourse("001", "CS002");
        manager.studentSelectCourse("001", "CS003");
        manager.studentSelectCourse("001", "CS004");
        manager.studentSelectCourse("001", "CS005");
        manager.studentSelectCourse("002", "CS001");
        manager.studentSelectCourse("002", "CS002");
        manager.studentSelectCourse("002", "CS003");
        manager.studentSelectCourse("003", "CS004");
        manager.studentSelectCourse("003", "CS005");
        manager.studentSelectCourse("004", "CS001");
        manager.studentSelectCourse("005", "CS002");
        manager.studentSelectCourse("005", "CS003");
        manager.studentSelectCourse("005", "CS004");
        manager.studentSelectCourse("006", "CS005");
        manager.studentSelectCourse("006", "CS001");
        manager.studentSelectCourse("006", "CS002");
        manager.studentSelectCourse("007", "CS003");
        manager.studentSelectCourse("008", "CS004");
        manager.studentSelectCourse("009", "CS005");
    }

}
